/**
 * Created by Administrator on 2016/12/12 0012.
 */

var WEB_INDEX = {
    WEB_HOME: 1,
    WEB_USER: 2,
    WEB_REPORT: 3,
    WEB_ANNOUNCE:4,
}

var ACCESS_TYPE = {
    ACCESS_ADMIN: 1,
    ACCESS_SERVER: 2,
    ACCESS_REPORT: 3,
}

function showTabControl(webIndex) {
    switch (webIndex) {
        /*首页非admin用户，不显示用户选项页*/
        case WEB_INDEX.WEB_HOME: {
            $.getJSON("/loginAccess", function (data, status) {
                if (status == "success") {

                    if (data.access == ACCESS_TYPE.ACCESS_ADMIN) {
                        var userTab = document.getElementById("idUserCfgTab");
                        userTab.style.display = "block";
                    }
                }
            });
        };
            break;
        /*到达user页面的肯定是admin用户,report界面需要检查是否显示user和adminhome页面*/
        case WEB_INDEX.WEB_REPORT:
            {
            $.getJSON("/loginAccess", function (data, status) {
                if (status == "success") {
                    switch (data.access) {
                        case ACCESS_TYPE.ACCESS_ADMIN: {
                            var homeTab = document.getElementById("idhomeTab");
                            homeTab.style.display = "block";
                            var userTab = document.getElementById("idUserCfgTab");
                            userTab.style.display = "block";
                            break;
                        }
                        case ACCESS_TYPE.ACCESS_SERVER: {
                            var homeTab = document.getElementById("idhomeTab");
                            homeTab.style.display = "block";
                            break;
                        }
                        case ACCESS_TYPE.ACCESS_REPORT:
                        {
                            //检查是什么权限
                        }
                        default: {
                            break;
                        }
                    }

                }
            });
        }
        case WEB_INDEX.WEB_ANNOUNCE: {
            $.getJSON("/loginAccess", function (data, status) {
                if (status == "success") {
                    switch (data.access) {
                        case ACCESS_TYPE.ACCESS_ADMIN: {
                            var homeTab = document.getElementById("idhomeTab");
                            homeTab.style.display = "block";
                            var userTab = document.getElementById("idUserCfgTab");
                            userTab.style.display = "block";
                            break;
                        }
                        case ACCESS_TYPE.ACCESS_SERVER: {
                            var homeTab = document.getElementById("idhomeTab");
                            homeTab.style.display = "block";
                            break;
                        }
                        case ACCESS_TYPE.ACCESS_REPORT:
                        {
                            var homeTab = document.getElementById("idhomeTab");
                            homeTab.style.display = "none";
                            var userTab = document.getElementById("idUserCfgTab");
                            userTab.style.display = "none";
                            var idAnnounceTab = document.getElementById("idAnnounceTab");
                            idAnnounceTab.style.display = "none"
                            break;
                        }
                        default: {
                            break;
                        }
                    }

                }
            });

            break;
        }
    }


}




